<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

<ui:composition>

    <p:panel id="pnlCredit" header="Créditos" widgetVar="panelCredit"  >

        <p:dataTable id="dataTableCredit" var="credit" value="#{financesDashboardMBean.listCredit}" rowKey="#{credit.pkCredit}" selection="#{financesDashboardMBean.selectedCredit}"
                     selectionMode="single" update="panel_edit_credit" paginator="true" rows="10" paginatorPosition="top">

            <p:column width="70">
                <f:facet name="header">Conta</f:facet>
                <h:outputText value="#{credit.bankAccount.name}">
                    <f:convertNumber type="currency" currencySymbol="R$" locale="pt" minFractionDigits="2" maxFractionDigits="2" />
                </h:outputText>
            </p:column>

            <p:column width="70">
                <f:facet name="header">Valor</f:facet>
                <h:outputText value="#{credit.value}">
                    <f:convertNumber type="currency" currencySymbol="R$" locale="pt" minFractionDigits="2" maxFractionDigits="2" />
                </h:outputText>
            </p:column>

            <p:column width="90">
                <f:facet name="header">Registrado</f:facet>
                <h:outputLabel value="#{credit.datetimeRegistered}">
                    <f:convertDateTime pattern="dd/MM hh:mm:ss"/>
                </h:outputLabel>
            </p:column>

            <p:column>
                <f:facet name="header">Descrição</f:facet>
                <h:outputText value="#{credit.description}"/>
            </p:column>
        </p:dataTable>

        <p:commandButton value="Criar" styleClass="btn" onclick="create_credit.show()" rendered="#{logonMBean.login.loginRulesView.root}"/>
        <p:commandButton value="Editar" styleClass="btn" onclick="edit_credit.show()" rendered="#{logonMBean.login.loginRulesView.root}"/>
        <p:commandButton value="Apagar" styleClass="btn" actionListener="#{financesDashboardMBean.removeCredit}" update="dataTableCredit" rendered="#{logonMBean.login.loginRulesView.root}"/>
    </p:panel>
</ui:composition>
</html>